﻿#ifndef __AVOID_CONTROL_IMAGE_QUEUE_HEAD_FILE_CINCLUDED__
#define __AVOID_CONTROL_IMAGE_QUEUE_HEAD_FILE_CINCLUDED__
#include "ctlImage.h"
#include <vector>

namespace swui
{
	class ctlImageQueue
	{
		ctlImageQueue(const ctlImageQueue&);
	public:
		ctlImageQueue() {}
		//添加字体到图像，返回索引
		unsigned addImage(std::shared_ptr<ctlImage>);
		//设置队列的图像
		bool setImage(unsigned index, std::shared_ptr<ctlImage>);
		//获取队列大小
		unsigned getQueueSize();
		//获取队列中的元素
		std::shared_ptr<ctlImage> getElement(unsigned index);
	private:
		std::vector<std::shared_ptr<ctlImage>> _data;
	};

	inline std::shared_ptr<ctlImage> ctlImageQueue::getElement(unsigned index)
	{
		if(index >= getQueueSize())
			return std::shared_ptr<ctlImage>(nullptr);
		return _data[index];
	}
	inline unsigned ctlImageQueue::addImage(std::shared_ptr<ctlImage> img) {
		_data.push_back(img);
		return _data.size() - 1;
	}
	inline bool ctlImageQueue::setImage(unsigned index, std::shared_ptr<ctlImage> img) {
		if(getQueueSize() <= index) return false;
		_data[index] = img;
		return true;
	}
	inline unsigned ctlImageQueue::getQueueSize() {
		return _data.size();
	}
}

#endif